import QtQuick 2.15
import QtQuick.Controls 2.15

ParaCalSubItem {
    id: root
    title: qsTr("校准")
    width: 784
    height: 338
    property color btnColor: "#7080C0"
    property bool gainCalOK:false
    onSignalOK: {
        if(paraCalLoader.visible){
            return;
        }
        var currentWeight =Number(curValue.text)
        if(currentWeight<0)
        {
            gainCalOKDialog.title=qsTr("输入值不能小于0！")
            gainCalOKDialog.open()
            return;
        }
        if(currentWeight > mymodbus.maxRange)
        {
            gainCalOKDialog.title=qsTr("输入值不能大于量程！")
            gainCalOKDialog.open()
            return;
        }
        paraCalLoader.visible=true
        paraCalView.signalSuccess()
//        if(mymodbus.gainCalibration(cmbGainIndex.currentIndex,currentWeight)){
//            paraCalView.signalSuccess()
//        }
//        else{
//            paraCalView.signalFailed()
//        }
        paraCalLoader.visible=false
        miniKeyBoard.buttonClean()
    }
    onSignalNext: {
    }
    onSignalPre: {
    }
    MyBuzyIndicator{
        anchors.centerIn: parent
        id: gainCalLoader
        visible:false
    }
    Rectangle {
        id: recCurrentValue
        width:180
        height:30
        color: "transparent"
        border.width: 0
        border.color: "white"
        TextInput{
            id:currentValue
            anchors.fill: parent
            text:qsTr("电压:")+mymodbus.current0.toString()+"mV"
            color:"white"
            font.pixelSize: 20
            horizontalAlignment: Text.AlignLeft
            verticalAlignment: Text.AlignBottom
            readOnly: true
            MouseArea {
                   anchors.fill: parent
                   onClicked: {
                   }
               }
            }
        }
    Dialog {
        anchors.centerIn: parent
        id: gainCalOKDialog
        modal:true
        closePolicy: "CloseOnEscape"
        standardButtons: Dialog.Ok
        title:qsTr("校准成功！")
        onAccepted: {
            gainCalOKDialog.close()
        }
        z:100
    }
}

